<template>
  <div>
    <span>{{ value ? "是" : "否" }}</span>
    <el-switch @change="changeValue" v-model="value" v-bind="$attrs" v-if="isShow"> </el-switch>
  </div>
</template>
<script>
export default {
  props: {
    id: {
      type: Number,
      default: 0
    },
    switchValue: {
      type: Boolean,
      default: false
    },
    handle:{
      type:String,
      default:""
    }
  },
  computed:{
    isShow(){
      return this.handle?this.hasPermissions(this.handle):true
    }
  },
  data() {
    return {
      value: this.switchValue
    };
  },
  watch: {
    switchValue(val) {
      this.value = val;
    }
  },
  methods: {
    changeValue() {
      this.$emit("change", { id: this.id, value: this.value });
    }
  }
};
</script>
